<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>系统彩预设管理</title>
<%@include file="/WEB-INF/base.jspf"%>
		<style>
 #test1,#hymc-period {
	 margin: 3px;  
	 height: 37px;
	 margin-bottom: 10px;
}

.roomNumber{
	background: #fff;
    border-radius: 5px;
    padding: 0 5px;
}

#test2,.ysnext {
	margin: 3px;
	height: 37px;
}
.modal-dialog {
		max-width: 1000px;
	}
.qblx, {
	margin: 2px;
	height: 37px;
}

.layui-inline {
	margin-bottom: 10px;
}

.hymc {
	margin: 3px;
	height: 37px;
}

#table_id_example_paginate{
 margin-right:100px;
}
.class-input-pageNumber{
    
	width:40px;
	height:23px;
	position: absolute;
	right:55px;
	top:12px;
}
.class-span-searchBtn{
	height:24px;
	width:36px;
	font-size:14px;
	text-algin:center;
	line-height:25px;
	padding:0!important;
	position: absolute;
	right:15px;
	top:12px;
}
.dataTables_length{
	margin-top:12px;
	margin-left:50px;
}
.layui-btn-radius{
	margin-bottom: 5px;
}
.btn-primary{
	margin-bottom: 3px;
}
.tableSearch{
    position: relative;
}
input{
	padding-left:5px;
}
table th,table tr,table td {
	text-align: center;
	vertical-align:middle;
}

.wapp{
	margin: 20px 0;
}

	.p-c-flexwrapper {
		display:flex;
		align-items:center;
		margin-right:16px;
		margin-bottom:16px;
	}
	.input-c-lotterNumber {
		width:450px;
		height:50px;
		margin-right:12px;
		margin-bottom:10px;
	    font-size: 22px;
  	    font-weight: bold;
	}
	.hidden-td {
		display:none;
	}
	
	
	.nav-fake {
padding-left: 0;
    margin-bottom: 20px;
    list-style: none;
}
.nav-tabs-fake>li {
float: left;
    margin-bottom: -1px;
}
.nav-fake>li {
position: relative;
    display: block;	
}
.nav-tabs-fake>li.active>a {
color: #555;
    cursor: default;
    background-color: #fff;
    border: 1px solid #ddd;
    border-bottom-color: transparent;	
}
.nav-tabs-fake>li>a {
margin-right: 2px;
    line-height: 1.42857143;
    border: 1px solid transparent;
    border-radius: 4px 4px 0 0;	
}
.nav-fake>li>a {
position: relative;
    display: block;
    padding: 10px 15px;	
}
.nav-tabs-fake:after {
	content:"";
	display:block;
	clear:both;
	}
.wapp{
	width:100%;
	height: 100%;
	padding:0 15px;
}	

.modal-header{
	text-align: center;
}	
.modal{
	width:100%;
}
.modal-head{
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 0;
    position: relative;
    padding: 0;
     padding: 5px 0;
    /*  border:1px solid #f5f5f5;  */
}
.modal-body{
	display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 0;
    padding: 0;
   /*  padding: 5px 0; */
  /*   border:1px solid #f5f5f5;  */
}
.wapp li{
	width:20%;
	height:auto;
	text-align: left;
	/* border:1px solid #f5f5f5; */
}

.pukeCard {
    width: 30px;
    border: 1px solid #666;
    height: 40px;
}
/* .bjldDefault p:first-child{
	
} */

.bjldDefault{
	overflow: hidden;
	display: none;
}

.bjlLeft{
	float: left;
}

.bjlRight{
	float: left;
	margin-left: 20px;
    padding-top: 30px;
}

.bjlRight p img{
	width: 30px;
    border: 1px solid #666;
    height: 40px;
}

.bjlRight p img:hover{
	transform: scale(1.4);
	margin: 0 10px;
	/* border: 1px solid #6666668a; */
	opacity:0.9;
	box-shadow:0 0 8px #DDD;
	-moz-box-shadow:0 0 8px #DDD;
	-webkit-box-shadow:0 0 8px #DDD;
}

.preset{
	margin-top: 30px;
}

.bjlLeft p{
	line-height: 40px;
	margin: 20px 0 !important;
}

.bjlLeft p em{
	display: inline-block;
    margin-right:10px;
    font-style: normal;
    border: 1px solid #928686;
    padding: 0 10px;
    color: #a28b8b;
    cursor: pointer;
}

.bjlLeft p em.active{
    border: 1px solid #c9ca29;
	color: darkgreen;
}

.bjlLeft p span{
	margin-left: 20px;
}

.bjlLeft p span:first-child{
	margin-left: 10px;
}

.bjlLeft p select{
	height: 40px;
	margin-right: 20px;
}

.layui-inline{
	width:100%;
}

.bjlRight p img{
	cursor: pointer;
}

.p-i-tips.active {
    visibility: visible;
}
.p-i-tips {
    margin-bottom: 20px;
    visibility: hidden;
}

#confirmKaiJiangModal .modal-body{
	display: block;
	padding: 25px;
	padding-bottom: 0;
}

#confirmKaiJiangModal .modal-dialog{
	width:380px;
}

#confirmKaiJiangModal .modal-body p{
	width:320px;
}

#confirmKaiJiangModal .modal-body span{
	width:80px;
	text-align: right;
}	 
	
</style>
	</head>
	<body>
		<div style="">
		<!-- <form id="form-i-placeholderForm"> -->
			<div class="layui-inline">
				<ul class="nav-fake nav-tabs-fake">
					<c:forEach items="${xitongcz}" var="i" varStatus="index">
						<c:if test="${i.cname!='bjl'}">
							<li class="${i.cname }"><a href="#identifier">${i.name }</a></li>
						</c:if>
					</c:forEach>
				</ul>
				<div class="layui-inline">
				<div style="display:block;">
					<div class='check'>	
						<input type="text" id="test1" data-search name="date" placeholder="开始时间" >
						<input type="text" id="test2" data-search name="date" placeholder="结束时间" >
						<input type="text" class="hymc" data-search name="period" id="hymc-period" placeholder="期号">
						<button class="layui-btn layui-btn-radius" id="btn_search">查询</button>
						<button class="layui-btn layui-btn-radius" id="button-i-resetTableContent" style="margin-left:5px;">重置</button><br>
					</div>
					<div class='preset'>	
						<p style="font-weight:bold;color:red;font-size:14px;width:750px;">注：显示的期号是预设的最新一期期号，倒计时的时间是正在开奖的一期       操作该功能请严格按照说明操作,如果随意操作导致系统异常,会被说的;输入开奖号码时，号码之间用英文输入法状态下的“,”隔开</p>
						<input type="text" class="ysnext" data-search name="period" id="next-looternumber" placeholder="预设下期号码" readonly>    
						<input type="text" class="ysnext" data-search name="time" id="time" value="" readonly>
					    <input type="text" class="ysnext" data-search name="period" id="p-i-lotterNumWrapper" class="p-c-flexwrapper lotterNumber-list" placeholder="请输入开奖号" style="width:300px;"> 
					   <button type="button" class="btn btn-primary" id="button-i-addNewQQNumber2">预设</button> 
				   </div> 
				   
				 <!--   <div class='bjldDefault'>
				   		<div class='bjlLeft'>
					   		<p><span>桌号：</span><select class='roomNumber'><option value="1">第一桌</option><option value="2">第二桌</option><option value="3">第三桌</option><option value="4">第四桌</option><option value="5">第五桌</option><option value="6">第六桌</option></select><button type="button" class="btn btn-primary" id="button-i-bjlCard">保存</button></p>
					   		<p><span>预设牌：</span><span>庄1牌：</span><em class="zhuang1">请选择</em><span>庄2牌：</span><em class="zhuang2">请选择</em><span class="zhuangBu" >庄补牌：</span><em class="dealerCard zhuangBu" >请选择</em></p>
					   		<p><span style='margin-left: 95px;'>闲1牌：</span><em class="leisure1">请选择</em><span>闲2牌：</span><em class="leisure2">请选择</em><span class="xianBu">闲补牌：</span><em class="leisureCard xianBu">请选择</em></p>
				   		</div>
				   		<div class='bjlRight'>
				   			<p class='heit'>
				   				<img class='pukeCard heita' alt="" src="/img/caizhong/bjl/heita.png">
				   				<img class='pukeCard heit2' alt="" src="/img/caizhong/bjl/heit2.png">
				   				<img class='pukeCard heit3' alt="" src="/img/caizhong/bjl/heit3.png">
				   				<img class='pukeCard heit4' alt="" src="/img/caizhong/bjl/heit4.png">
				   				<img class='pukeCard heit5' alt="" src="/img/caizhong/bjl/heit5.png">
				   				<img class='pukeCard heit6' alt="" src="/img/caizhong/bjl/heit6.png">
				   				<img class='pukeCard heit7' alt="" src="/img/caizhong/bjl/heit7.png">
				   				<img class='pukeCard heit8' alt="" src="/img/caizhong/bjl/heit8.png">
				   				<img class='pukeCard heit9' alt="" src="/img/caizhong/bjl/heit9.png">
				   				<img class='pukeCard heit10' alt="" src="/img/caizhong/bjl/heit10.png">
				   				<img class='pukeCard heitj' alt="" src="/img/caizhong/bjl/heitj.png">
				   				<img class='pukeCard heitq' alt="" src="/img/caizhong/bjl/heitq.png">
				   				<img class='pukeCard heitk' alt="" src="/img/caizhong/bjl/heitk.png">
				   			</p>
				   			<p class='hongt'>
				   				<img class='pukeCard hongta' alt="" src="/img/caizhong/bjl/hongta.png">
				   				<img class='pukeCard hongt2' alt="" src="/img/caizhong/bjl/hongt2.png">
				   				<img class='pukeCard hongt3' alt="" src="/img/caizhong/bjl/hongt3.png">
				   				<img class='pukeCard hongt4' alt="" src="/img/caizhong/bjl/hongt4.png">
				   				<img class='pukeCard hongt5' alt="" src="/img/caizhong/bjl/hongt5.png">
				   				<img class='pukeCard hongt6' alt="" src="/img/caizhong/bjl/hongt6.png">
				   				<img class='pukeCard hongt7' alt="" src="/img/caizhong/bjl/hongt7.png">
				   				<img class='pukeCard hongt8' alt="" src="/img/caizhong/bjl/hongt8.png">
				   				<img class='pukeCard hongt9' alt="" src="/img/caizhong/bjl/hongt9.png">
				   				<img class='pukeCard hongt10' alt="" src="/img/caizhong/bjl/hongt10.png">
				   				<img class='pukeCard hongtj' alt="" src="/img/caizhong/bjl/hongtj.png">
				   				<img class='pukeCard hongtq' alt="" src="/img/caizhong/bjl/hongtq.png">
				   				<img class='pukeCard hongtk' alt="" src="/img/caizhong/bjl/hongtk.png">
				   			</p>
				   			<p class='meih'>
				   				<img class='pukeCard meiha' alt="" src="/img/caizhong/bjl/meiha.png">
				   				<img class='pukeCard meih2' alt="" src="/img/caizhong/bjl/meih2.png">
				   				<img class='pukeCard meih3' alt="" src="/img/caizhong/bjl/meih3.png">
				   				<img class='pukeCard meih4' alt="" src="/img/caizhong/bjl/meih4.png">
				   				<img class='pukeCard meih5' alt="" src="/img/caizhong/bjl/meih5.png">
				   				<img class='pukeCard meih6' alt="" src="/img/caizhong/bjl/meih6.png">
				   				<img class='pukeCard meih7' alt="" src="/img/caizhong/bjl/meih7.png">
				   				<img class='pukeCard meih8' alt="" src="/img/caizhong/bjl/meih8.png">
				   				<img class='pukeCard meih9' alt="" src="/img/caizhong/bjl/meih9.png">
				   				<img class='pukeCard meih10' alt="" src="/img/caizhong/bjl/meih10.png">
				   				<img class='pukeCard meihj' alt="" src="/img/caizhong/bjl/meihj.png">
				   				<img class='pukeCard meihq' alt="" src="/img/caizhong/bjl/meihq.png">
				   				<img class='pukeCard meihk' alt="" src="/img/caizhong/bjl/meihk.png">
				   			</p>
				   			<p class='fangp'>
				   				<img class='pukeCard fangpa' alt="" src="/img/caizhong/bjl/fangpa.png">
				   				<img class='pukeCard fangp2' alt="" src="/img/caizhong/bjl/fangp2.png">
				   				<img class='pukeCard fangp3' alt="" src="/img/caizhong/bjl/fangp3.png">
				   				<img class='pukeCard fangp4' alt="" src="/img/caizhong/bjl/fangp4.png">
				   				<img class='pukeCard fangp5' alt="" src="/img/caizhong/bjl/fangp5.png">
				   				<img class='pukeCard fangp6' alt="" src="/img/caizhong/bjl/fangp6.png">
				   				<img class='pukeCard fangp7' alt="" src="/img/caizhong/bjl/fangp7.png">
				   				<img class='pukeCard fangp8' alt="" src="/img/caizhong/bjl/fangp8.png">
				   				<img class='pukeCard fangp9' alt="" src="/img/caizhong/bjl/fangp9.png">
				   				<img class='pukeCard fangp10' alt="" src="/img/caizhong/bjl/fangp10.png">
				   				<img class='pukeCard fangpj' alt="" src="/img/caizhong/bjl/fangpj.png">
				   				<img class='pukeCard fangpq' alt="" src="/img/caizhong/bjl/fangpq.png">
				   				<img class='pukeCard fangpk' alt="" src="/img/caizhong/bjl/fangpk.png">
				   			</p>
				   		</div>
				   </div> -->
				    <p style="font-size:14px;font-weight:bold;color:red;" class="p-i-noticeText">占位符</p>
				</div>
				
				</div>
				<div class="layui-inline">
				</div>
			</div>
			<!-- </form> -->
				<div class="wapp">
	            </div>
	            
			<div>
 				<table id="table_id_example" class="class-tableDataTable table table-striped table-bordered table-hover">
					<thead>
						<tr>
							<th style="display:none;"></th>
							<th style="display:none;">彩种名称</th>
							<th>彩种名称</th>
							<th>预设期号</th>
							<th>预设号码</th>
							<th>开奖时间</th>
							<th>状态</th>
							<!--  <th>操作</th> -->
						</tr>
					</thead>
					<tbody>
					</tbody>
				</table>
			</div>
			
			<table id="table_id_bjl" class="class-tableDataTable table table-striped table-bordered table-hover" style='display:none;'>
					<thead>
						<tr>
							<th style="display:none;"></th>
							<th>预设期号</th>
							<th>预设庄1牌</th>
							<th>预设庄2牌</th>
							<th>预设庄补牌</th>
							<th>预设闲1牌</th>
							<th>预设闲2牌</th>
							<th>预设闲补牌</th>
							<th>桌号</th> 
							<th>开奖时间</th>
							<th>状态</th>
							<!--  <th>操作</th> -->
						</tr>
					</thead>
					<tbody>
					</tbody>
				</table>
		</div>
		
	
<%-- 	<div class="modal fade" id="updAndEditModal" tabindex="-1" role="dialog" aria-labelledby="updAndEditModal" aria-hidden="true">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
						<h4 class="modal-title" id="myModalLabel">新增/修改</h4>
					</div>
					<div class="modal-body">
					<input id="input-i-id" hidden="hidden" class="input-auto" />
					<form>
						<div style="display:flex;flex-direction:column;">
						<p style="display:flex;align-items:center;">
							<span style="width:90px;display:inline-block;">选择彩种:</span>
							<select style="width:auto;flex-grow:1;margin:0;" class="qblx form-control" id="qblx-cname2" required>
							    <c:forEach items="${xitongcz}" var="i" varStatus="index">
		                           <option value="${i.cname}">&nbsp;&nbsp;${i.name}</option>					    
							    </c:forEach>
							</select>
						</p>
						<!-- <p style="font-weight:bold;color:red;font-size:14px;">注：默认显示当前最新的期号，请修改为下一期的期号</p> -->
						<p style="display:flex;align-items:center;"><span style="width:90px;display:inline-block;">下一期期号:</span><input required style="width:auto;flex-grow:1;" class="form-control qihaoText-input" /></p>
						<p style="font-size:14px;font-weight:bold;color:red;" class="p-i-noticeText">占位符</p>
						<div style="display:flex;">
							<span style="margin-top:15px;">开奖号码：</span>
			             	<p >
			            	</p> 
						</div>
						
		            	</div>
					</form>
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-primary" id="button-i-addNewQQNumber2">提交更改</button>
						<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
					</div>
				</div>
			</div>
		</div> --%>
		
<div class="modal fade" id="noticeModal" tabindex="-1" role="dialog" aria-labelledby="noticeModal" aria-hidden="true">
    <div class="modal-dialog class-fake-alert">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            </div>
            <div class="modal-body" ></div>
            <div class="modal-footer">	      
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>   		
	
	
<div class="modal fade" id="confirmKaiJiangModal" tabindex="-1" role="dialog" aria-labelledby="confirmKaiJiangModal" aria-hidden="true">
    <div class="modal-dialog class-fake-alert">
        <div class="modal-content">
            <div class="modal-header">
            	<span >修改预设号码</span>
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            </div>
            <div class="modal-body" >
            	<p style="display:flex;align-items:center;margin-right: 50px;"><span >期号：</span><input required="required" style='width:auto;flex-grow:1;' class='form-control next-qihao-input' readonly /></p>
            	<p style="display:flex;align-items:center;"><span >开奖号码：</span><input id="p-i-lotterNumWrapper1" required="required" style='width:auto;flex-grow:1;' class='form-control next-kjhm-input' /></p>
            	<p style="font-size:14px;font-weight:bold;color:red;" class="p-i-tips">占位符</p>
            </div>
            <div class="modal-footer">	      
           	    <button type="button" class="btn btn-primary btn-upData-kjhm" >确认</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>   			
			
			
	<script type="text/javascript" src="/js/caizhongyusheLotterHelper.js"></script>	
	<script type="text/javascript" src="/js/zhengzeTools.js"></script>
	<script>
		/* layui时间插件 */
		layui.use('laydate', function() {
			var laydate = layui.laydate;
			laydate.render({
				elem : '#test1' //指定元素
			});
			 laydate.render({
				elem : '#test2' //指定元素
			}); 
		}); 
		var ROLEOBJ 
		var daojishi
		var oTable
		var index;
		/* 显示预设的数据 */
		var sajaxsource="/czgl/findByConditionSystemLotteryPresetRecord.do"
		 function DataTable01(sajaxsource){
			oTable=	$("#table_id_example").DataTable({
					 "bProcessing" : false, // 是否显示取数据时的那个等待提示
					"bServerSide" : true,//这个用来指明是通过服务端来取数据
					 "bPaginate" : true, //是否显示分页 
					"sAjaxSource" : sajaxsource,//这个是请求的地址
					"fnServerData" : retrieveData, // 获取数据的处理函数
					"destroy":true,
				      // "bPaginate": true,
				       "bLengthChange": true,      
				      "bSort": false,
				      // "bInfo": true,
				      "bAutoWidth": false,
//				         "bServerSide":true,
				      'aLengthMenu':[5,10, 20], 
				       "searching": false,  
				       "pagingType": "simple_numbers",
				       "dom": "t<'tableinfo'i<'tableSearch'p>l>", 
				       
				       "language": {//语言设置  
				            "lengthMenu": "每页显示 _MENU_ 条记录",     
				            "zeroRecords": "没有检索到数据",     
				            "sInfo": "当前显示 _START_ 到 _END_ 条，共 _TOTAL_ 条记录",     
				            "info": "没有数据",     
				            "oPaginate": {     
				                "sFirst": "首页",     
				                "sPrevious": "前一页",     
				                "sNext": "后一页",     
				                "sLast": "尾页"    
				          	},
				            "search":"",
				            "searchPlaceholder": "请输入关键字",
				            "infoFiltered":   "(从  _MAX_ 记录中搜索出结果)",
				            "infoEmpty":      "没有找到匹配的信息",
				         },  
				         "columnDefs": [{"defaultContent": "",
                             "targets": "_all"}],
				        "aoColumns": [
						 	 {"data": "id", "className": "hidden-td id-td"},
		                     {"data": "cname", "className": "hidden-td cname-td"},
		                     {"data": "gameNameInChinese", "className": "gameNameInChinese-td"},
		                     {"data": "period", "className": "period-td"},
		                     {"data": "lotterNumber", "className": "orderNum-td"},
		                     {"data": "lotterTime", "className": "careateTime-td"},
		                     {"data": "state", "className": "state-td"},
		                 ], 
		                 "drawCallback": function(result) {
		                	 if($("#table_id_example tbody tr").eq(0).find(".orderNum-td").text()==""){
	                			 $("#table_id_example tbody tr").eq(0).remove(); 
		                	} 
		                 }
				})

	function retrieveData(sSource, aoData, fnCallback) {
				var startIndex = aoData[3].value
				$.ajax({
					url : sSource,//这个就是请求地址对应sAjaxSource
					data : {
						"pageCount": aoData[0].value,
						"startIndex":aoData[3].value,
						"lineCount":aoData[4].value,
						 "cname":caizhong,
						 "period":$("#hymc-period").val(),
						 "date1":$("#test1").val(), 
						 "date2":$("#test2").val(), 
					},//这个是把datatable的一些基本数据传给后台,比如起始位置,每页显示的行数
					type : 'post',
					dataType : 'json',
					async : false,
					success : function(result) { 
						var newData = result.aaData
						var nextTime = result.replace2
						if(newData!=""){
							cname = newData[0].cname
							bindLotterType(cname)//拿到彩种的类型
							if(newData==""){
								return;
							}
							if(startIndex == 0){
								var item = newData[0]
								if(item.state == "已开奖"){
									/* $("#button-i-addNewQQNumber2").text("预设") */
									if(newData[0].nextperiod != null){
										$("#next-looternumber").val(newData[0].nextperiod)
									}else{
										$("#next-looternumber").val(newData[0].period)
									}
									var curTime=new Date(result.time).getTime(); //当前系统毫秒时间
									var nextTime=new Date(nextTime).getTime();//下棋开奖时间
									var countdown=(nextTime-curTime)/1000;  //倒计时时间
									if(isNaN(countdown)){ 
										daojishi = 0;
									}else{
										daojishi = countdown
									}
								}
								if(item.state == undefined){
									/* $("#button-i-addNewQQNumber2").text("保存") */
									cname = newData[0].cname
									if(newData[0].nextperiod != null){
										$("#next-looternumber").val(newData[0].nextperiod)
									}else{
										$("#next-looternumber").val(newData[0].period)
									}
									var curTime=new Date(result.time).getTime(); //当前系统毫秒时间
									var nextTime=new Date(nextTime).getTime();//下棋开奖时间
									var countdown=(nextTime-curTime)/1000;  //倒计时时间
									if(isNaN(countdown)){ 
										daojishi = 0;
									}else{
										daojishi = countdown
									}
								}
							}
			        	 	for (var i = 0; i < newData.length; i++) {
			        	 		var item = newData[i]
			        			if (item.state != "已开奖") {
			        				/* item.editBtn = '<button class="btn btn-success btn-c-paijiangBtn">修改</button>' */
			        					 //item.state="未开奖" 
			        					item.lotterTime="待开奖"
			        					item.state='<button class="btn btn-success btn-c-paijiangBtn btn-updataLotter">修改</button>'
			        			} else {
			        				item.state = "已开奖"
			        			}
			        	 		
			        	 		
			        		} 
						}
						result.aaData = newData;
						fnCallback(result);//把返回的数据传给这个方法就可以了,datatable会自动绑定数据的
					},
					error : function(msg) {
					}
				});
			}
		}
		DataTable01(sajaxsource)
		
		/* 修改开奖号码 */
		$("#table_id_example").on("click",".btn-updataLotter",function(){
			index=$(this).index();
			if($(this).parent().prev().prev().text() == ""){
				layer.msg("请先预设开奖号码")
				return;
			}
			$(".next-qihao-input").val($(this).parent().prev().prev().prev().text());
			$(".next-kjhm-input").val($(this).parent().prev().prev().text());
			$("#confirmKaiJiangModal").modal("show")
			var lotterNumber=$("#p-i-lotterNumWrapper1").val()
			lotterNumber=lotterNumber.substring(0,lotterNumber.length-1);
			$("#p-i-lotterNumWrapper1").val(lotterNumber)
			lotterInputListener("#p-i-lotterNumWrapper1",".p-i-tips")
		})
		
		/* 确认修改 */
		$(".btn-upData-kjhm").on("click",function(){
			if($(".next-qihao-input").val() == ""){
				layer.msg("期号不能为空");
				return;
			}
			if($("#table_id_example tbody tr").eq(index).find(".state-td").text()=="已开奖"){
				layer.msg("本期已开奖，无法修改");
				$("#confirmKaiJiangModal").modal("hide");
				return;
			}
			if($(".p-i-tips").hasClass("active")){
				layer.msg("请填写正确的信息");
				return;
			}
			var lotterNumber=$("#p-i-lotterNumWrapper1").val()+",";
			
			$.ajax({
				url : "/czgl/systemLotterUpData.do",
				data : {
					cname:$(".nav-tabs-fake .active").prop("className").split(" ")[0],
					period:$(".next-qihao-input").val(),
					lotternumber:lotterNumber,
				},
				type : 'post',
				success : function(data) { 
					if(data.data != -1){
						$("#confirmKaiJiangModal").modal("hide")
						DataTable01(sajaxsource)
						layer.msg("操作成功！")
					}else{
						layer.msg("操作失败！请检查期号和开奖号")
					}
				}
			})
		})
	     var caizhong=""
		$(".nav-fake").find("li").eq(0).addClass("active")
		
		/* 切换彩种 */
		$(".nav-fake li").on("click",function(){
			$(this).addClass("active").siblings("li").removeClass("active");
			$("#hymc-period").val("")
			if($(this).find("a").text()!="百家乐"){
				$(".bjldDefault").hide();
				$("#table_id_example").show();
				$("#table_id_bjl_wrapper").hide();
				$("#p-i-lotterNumWrapper").show();
				$("#button-i-addNewQQNumber2").show();
			 	sajaxsource="/czgl/findByConditionSystemLotteryPresetRecord.do" 
				caizhong=$(this).attr("class").split(" ")[0];
				DataTable01(sajaxsource)
				$("#p-i-lotterNumWrapper").val("")
				/* if($("#table_id_example_wrapper tbody tr").length==0){
					$("#button-i-addNewQQNumber2").text("保存")
				}else if($("#table_id_example_wrapper tbody tr").children("td:last-child")[0].innerHTML=="未开奖"){
					$("#button-i-addNewQQNumber2").text("修改")
				}else{
					$("#button-i-addNewQQNumber2").text("保存")
					$("#p-i-lotterNumWrapper").val("")
				} */
			}else{   /*展示bjl的数据  */
				/* $("#table_id_example_wrapper").hide();
				$("#table_id_bjl").show();
				$(".bjldDefault").show();
				$("#p-i-lotterNumWrapper").hide();
				$("#button-i-addNewQQNumber2").hide();
				DataTable02()
				if($("#table_id_bjl tbody tr").children("td:last-child")[0].innerHTML=="待开奖"){
					$("#button-i-bjlCard").text("修改")
				}else{
					$("#button-i-bjlCard").text("保存")
					$("#p-i-lotterNumWrapper").val("")
				} */
			}
		})
		
		
		/* 点击预设 */
		$("#button-i-addNewQQNumber2").click(function(event) {
			if($("#p-i-lotterNumWrapper").val()==""){
				layer.msg("请输入开奖号码");
				return;
			}
			if($(".active").find("a").text()=="百家乐"){
				return;
			}
			bindLotterType(cname)
			var period = $("#next-looternumber").val()
			var cnames=$(".nav-tabs-fake .active a").text();
			var lotternumber = $("#p-i-lotterNumWrapper").val()+","
			var lotterData=CAIZHONG_OBJ[lotterType];
			lotternumber = mixLooterNumber("#p-i-lotterNumWrapper")
			var num = lotternumber.split(",")
			for(var i = 0;i<num.length;i++){
				if(num[i] === ""){
					num.splice(i);
				}
			}
			if(num.length!=lotterData.weishu){
				$(".p-i-noticeText").addClass("active").text("开奖号码填写位数有误,请仔细检查") 
				return
			}
			if($(".p-i-noticeText").hasClass("active")){
				return false;
			}
			 var newRequest = {
				type: "post",
				url: "/czgl/systemLotteryPresetCheckNum.do",
				data: {
					period:period,
					cname: cname,
					lotternumber: lotternumber,
					gameNameInChinese: cnames,
					type: "1",
					
				},
				success: function(data) {
					var newData = JSON.parse(data)
					if(newData.data == 1){
						layer.msg("操作成功！")
					}
					if(newData.data == 10){
						layer.msg("请填写下期期号！")
					}
					$("#table_id_example").DataTable().ajax.reload()
				},
				error: function(status) {
				}
			}
			ajax(newRequest)
		})
	
				
				
			 /* 查询 */
			 $("#btn_search").on("click",function(){
				 if($("#test1").val()=="" && $("#test2").val()=="" && $("#hymc-period").val()==""){
					 return;
				 }else{
					 if($(".nav-fake .active a").text()!='百家乐'){
						  sajaxsource="/czgl/findByConditionSystemLotteryPresetRecord.do"
						caizhong=$(".nav-fake li.active")[0].className.split(" ")[0]
							 DataTable01(sajaxsource) 
					 }else{
						 DataTable02()
					 }
				 }
			 })
			 
			 /* 重置 */
			 $("#button-i-resetTableContent").on("click",function(){
				 $("#hymc-period").val("")
				 $("#test1").val("")
				 $("#test2").val("")
				 if($(".nav-fake .active a").text()!='百家乐'){
					 	sajaxsource="/czgl/findByConditionSystemLotteryPresetRecord.do"
						 $("#p-i-lotterNumWrapper").val("")
						 $(".p-i-noticeText").removeClass("active")
						 DataTable01(sajaxsource) 
				 }else{
					 $(".bjlLeft em").removeClass("active");
					 $(".bjlLeft em").text("请选择");
					 $(".bjlLeft em").css("border","1px solid #928686");
					/*  DataTable02() */
				 }
				  
			 })	
				
			 setInterval(DaoJiShi, 1000);
			 /* 倒计时 */
			 function DaoJiShi(){
				 if($("#table_id_example").find(".dataTables_empty").length==1){
					 return;
				 }
				daojishi--;
			 	var h = parseInt(daojishi/ 60 / 60 % 60) //时
			    var m = parseInt(daojishi/ 60 % 60)  //分
			 	var s = parseInt(daojishi% 60)  //秒
			 	if(h <= 0 && m <= 0 && s <= 0){
				 	$("#time").val("正在开奖")
				 	if($(".nav-fake .active").find("a").text()!='百家乐'){
				 		  DataTable01(sajaxsource)
				 	}else{
				 		 DataTable02()
				 	}
			 	}else{
			 		$("#time").val(h+":"+m+":"+s)
				}
			 } 
			 
			 /* 输入错误时给出提示 */
			 lotterInputListener("#p-i-lotterNumWrapper",".p-i-noticeText")
			 
			 
			 
			 bandxiazhu()
			 /* 显示用户的下注记录 */
			 function bandxiazhu(){
				 ajax({
					 type: "post",
						url: "/czgl/findByCnameAndPeriodChekcInfo.do",
						data: {
							period:$("#next-looternumber").val(),
							cName: cname,
						},
						success: function(data) {
							$(".wapp").html("")
							var newData = JSON.parse(data)
							 if(newData.data==""){
								 return
							 } 
							var html="<ul class='modal-head'>"+
							  			"<li>投注账号</li>"+
							  			"<li>投注时间</li>"+
							  			"<li>投注金额</li>"+
							  			"<li>投注玩法</li>"+
							  			"<li>投注号码</li>"+
						  		  	 "</ul>"
							
							 for(var i = 0;i<newData.data.length;i++){
								 var wanfa=[]
								 var touzhuma=[]
								 var item = newData.data[i];
								 for (var j = 1; j < 41; j++) {
									 if(item["cplay" + j]!=null){
										 wanfa.push(item["cplay" + j])
										 touzhuma.push(item["str" + j])
									 }
								 }
								 var html2=""
								 var html3=""
								 for(j=0;j<wanfa.length;j++){
									 html2+="<div>"+wanfa[j]+"</div>"
									 html3+="<div>"+touzhuma[j]+"</div>"
								 }
								 html+="<ul class='modal-body'><li>"+item.huiyuanzh+"</li><li>"+item.orderdate+"</li><li>"+item.acount+"</li><li>"+html2+"</li><li>"+html3+"</li></ul>"
							} 
							  $(".wapp").append(html)
						}
				 })
			 }
			 
			
			 
	/* ================================百家乐数据，暂不使用请不要删除=============================== */		 
		/* 	 
			 //百家乐表数据
			  function DataTable02(){
			var oTable=	$("#table_id_bjl").DataTable({
					 "bProcessing" : false, // 是否显示取数据时的那个等待提示
					"bServerSide" : true,//这个用来指明是通过服务端来取数据
					 "bPaginate" : true, //是否显示分页 
					"sAjaxSource" : "/bjlhtgl/lotteryRecord.do",//这个是请求的地址
					"fnServerData" : retrieveData, // 获取数据的处理函数
					"destroy":true,
				      // "bPaginate": true,
				       "bLengthChange": true,      
				      "bSort": false,
				      // "bInfo": true,
				      "bAutoWidth": false,
//				         "bServerSide":true,
				      'aLengthMenu':[5,10, 20], 
				       "searching": false,  
				       "pagingType": "simple_numbers",
				       "dom": "t<'tableinfo'i<'tableSearch'p>l>", 
				       
				       "language": {//语言设置  
				            "lengthMenu": "每页显示 _MENU_ 条记录",     
				            "zeroRecords": "没有检索到数据",     
				            "sInfo": "当前显示 _START_ 到 _END_ 条，共 _TOTAL_ 条记录",     
				            "info": "没有数据",     
				            "oPaginate": {     
				                "sFirst": "首页",     
				                "sPrevious": "前一页",     
				                "sNext": "后一页",     
				                "sLast": "尾页"    
				          	},
				            "search":"",
				            "searchPlaceholder": "请输入关键字",
				            "infoFiltered":   "(从  _MAX_ 记录中搜索出结果)",
				            "infoEmpty":      "没有找到匹配的信息",
				         },  
				         "columnDefs": [{"defaultContent": "",
                             "targets": "_all"}],
				        "aoColumns": [
						 	 {"data": "id", "className": "hidden-td id-td"},
		                     {"data": "issueNumber", "className": "issueNumber-td"},
		                     {"data": "zhuang1", "className": "zhuang1-td"},
		                     {"data": "zhuang2", "className": "zhuang2-td"},
		                     {"data": "dealerCard", "className": "dealerCard-td"},
		                     {"data": "leisure1", "className": "leisure1-td"},
		                     {"data": "leisure2", "className": "leisure2-td"},
		                     {"data": "leisureCard", "className": "leisureCard-td"},
		                     {"data": "tableNumber", "className": "tableNumber-td"}, 
		                     {"data": "openingTimeOfTheCurrentAward", "className": "openingTimeOfTheCurrentAward-td"},
		                     {"data": "state", "className": "state-td"},
		                 ], 
				})
			
	function retrieveData(sSource, aoData, fnCallback) {
				var startIndex = aoData[3].value
				$.ajax({
					url : sSource,//这个就是请求地址对应sAjaxSource
					data : {
						"pageCount": aoData[0].value,
						"startIndex":aoData[3].value,
						"lineCount":aoData[4].value,
						"tableNumber":$(".roomNumber").val(),
						"time1":$("#test1").val(),
						"time2":$("#test2").val(),
						"period":$("#hymc-period").val(),
					},//这个是把datatable的一些基本数据传给后台,比如起始位置,每页显示的行数
					type : 'post',
					dataType : 'json',
					async : false,
					success : function(result) { 
						var newJson = result.aaData
						if(newJson==""){
							return;
						}
						 for (var i = 0; i < newJson.length; i++) {
		         			 var item = newJson[i]
		         			 if(item.state==1){
		         				item.state="已开奖"
		         			 }if(item.state==0){
		         				item.state="未开奖"
		         			 }if(item.state==2){
		         				item.state="已预设"
		         			 }
						
						if(startIndex == 0){
							var items = newJson[0]
							if(items.state == "已开奖"){
								$("#button-i-bjlCard").text("保存")
								$("#next-looternumber").val(newJson[0].nextIssueNumber)
								var curTime=new Date(result.time).getTime(); //当前系统毫秒时间
								var nextTime=new Date(newJson[0].nextTime).getTime();//下棋开奖时间
								var countdown=(nextTime-curTime)/1000;  //倒计时时间
								countdown=countdown-15;
								if(isNaN(countdown)){ 
									daojishi = 0;
								}else{
									daojishi = countdown
								}
							}
							if(items.state == "已预设"){
								$("#button-i-bjlCard").text("修改")
								$("#next-looternumber").val(newJson[1].nextIssueNumber)
								var curTime=new Date(result.time).getTime(); //当前系统毫秒时间
								var nextTime=new Date(newJson[1].nextTime).getTime();//下棋开奖时间
								var countdown=(nextTime-curTime)/1000-15;  //倒计时时间
								if(isNaN(countdown)){ 
									daojishi = 0;
								}else{
									daojishi = countdown
								}
							}
						}
		        	
						item.zhuang1="<img class='pukeCard'  src='/img/caizhong/bjl/" + item.zhuang1 + ".png'>"
	         			 item.zhuang2="<img class='pukeCard' src='/img/caizhong/bjl/" + item.zhuang2 + ".png'>"
	         			 if(item.dealerCard!=undefined && item.dealerCard!="" && item.dealerCard!=null){
		         				item.dealerCard="<img class='pukeCard'  src='/img/caizhong/bjl/" + item.dealerCard + ".png'>"
		         			 }
		         			
	         			 item.leisure1="<img class='pukeCard' src='/img/caizhong/bjl/" + item.leisure1 + ".png'>"
	         			 item.leisure2="<img class='pukeCard' src='/img/caizhong/bjl/" + item.leisure2 + ".png'>"
	         			 if(item.leisureCard!=undefined && item.leisureCard!="" && item.leisureCard!=null){
		         				item.leisureCard="<img class='pukeCard'  src='/img/caizhong/bjl/" + item.leisureCard + ".png'>"
		         			 }
		        		 }
						 result.aaData = newJson; 
				
						fnCallback(result);//把返回的数据传给这个方法就可以了,datatable会自动绑定数据的
					},
					error : function(msg) {
					}
				});
			}
		}
			 
		var zhuangCard=""; //庄的牌	
		var zxianCard; //闲的牌	
		
		//切换房间号
		$(".roomNumber").change(function(){
			DataTable02()
		})
			
		// 点击选牌
		$(".bjlLeft em").on("click",function(){
			 for(i=0;i<$(".bjlLeft em").length;i++){
				if($(".bjlLeft em").eq(i).find("img").length==0){
					$(".bjlLeft em").eq(i).text("请选择")
					$(".bjlLeft em").eq(i).css("border","1px solid #928686")
				}
			} 
			$(this).addClass("active")
			$(this).text("选牌中")
			$(this).siblings().removeClass("active")
			$(this).parent().siblings().find("em").removeClass("active")
			
			$(".bjlLeft .active").css("border","1px solid #c9ca29")
		})	
		
		// 确认选牌 
		$(".bjlRight img").on("click",function(){
			var card=$(this).attr("class").split(" ")[1]
			$(".bjlLeft .active").html("<img class='pukeCard "+card+"' alt='' src='/img/caizhong/bjl/"+card+".png'>")
			$(".bjlLeft .active").css("border","none");
			$(".bjlLeft .active").removeClass("active");
			
		})
		
		// 点击预设 
		$("#button-i-bjlCard").on("click",function(){
			var zhuang1=$(".zhuang1 img").attr("class").split(" ")[1];
			var zhuang2=$(".zhuang2 img").attr("class").split(" ")[1];
			if(zhuang1.indexOf("10")!=-1){
				zhuang1=zhuang1.substring(0,zhuang1.length-2)+",10"
			}else{
				zhuang1=zhuang1.substring(0,zhuang1.length-1)+","+zhuang1.substring(zhuang1.length-1,zhuang1.length)
			}
			if(zhuang2.indexOf("10")!=-1){
				zhuang2=zhuang2.substring(0,zhuang2.length-2)+",10"
			}else{
				zhuang2=zhuang2.substring(0,zhuang2.length-1)+","+zhuang2.substring(zhuang2.length-1,zhuang2.length)
			}
			var zhuangBu
			if($(".dealerCard img").length==0){
				zhuangBu=""
			}else{
				zhuangBu=$(".dealerCard img").attr("class").split(" ")[1];
				if(zhuangBu.indexOf("10")!=-1){
					zhuangBu=zhuangBu.substring(0,zhuangBu.length-2)+",10"
				}else{
					zhuangBu=zhuangBu.substring(0,zhuangBu.length-1)+","+zhuangBu.substring(zhuangBu.length-1,zhuangBu.length)
				}
			}
			var xian1=$(".leisure1 img").attr("class").split(" ")[1];
			var xian2=$(".leisure2 img").attr("class").split(" ")[1];
			if(zhuang1.indexOf("10")!=-1){
				xian1=xian1.substring(0,xian1.length-2)+",10"
			}else{
				xian1=xian1.substring(0,xian1.length-1)+","+xian1.substring(xian1.length-1,xian1.length)
			}
			if(xian2.indexOf("10")!=-1){
				xian2=xian2.substring(0,xian2.length-2)+",10"
			}else{
				xian2=xian2.substring(0,xian2.length-1)+","+xian2.substring(xian2.length-1,xian2.length)
			}
			var xianBu
			if($(".xianBu img").length==0){
				xianBu=""
			}else{
				xianBu=$(".xianBu img").attr("class").split(" ")[1];
				if(xianBu.indexOf("10")!=-1){
					xianBu=xianBu.substring(0,xianBu.length-2)+",10"
				}else{
					xianBu=xianBu.substring(0,xianBu.length-1)+","+xianBu.substring(xianBu.length-1,xianBu.length)
				}
			}
			Baccarat(zhuang1,zhuang2,zhuangBu,xian1,xian2,xianBu,$(".roomNumber").val(),$("#next-looternumber").val()) 
		})
		
		
		function Baccarat(zhuang1,zhuang2,zhuangBuBrand,xian1,xian2,leisureCard,tableNumber,issueNumber){
		var	arbitraryPairs = -1; //任意对子 0-没有任意对子  1有任意对子',
		var perfectPair = -1; //'完美对子 0-没有完美对子   1-有完美对子',
		var	size = -1; // '0-小   1-大',
		var zhuangPairs = -1; //庄对 0-没有庄对 1-有庄对
		var idleTime = -1; //闲对 0-没有闲对 1-有闲对
		var winner = -1; //开奖状态  0-闲家赢 1-庄家赢  2-和局
		var leisureHomePoints = -1;//闲家最终点数
		var makerSFinalPoints = -1; //庄家最终点数
		var frontPointsofIdleReplacementCards = -1; //闲家补牌前点数
		var frontPointsOfZhuangshi = -1;//庄家补牌前点数
		var leisureCards = "" ;//闲家补牌
		var leisures2 = ""; //闲家第二张牌
		var leisures1 = "" ;//闲家第一张牌
		var dealerCards = ""; //庄家补牌
		var zhuangs2 = "" ; //庄家开奖第二张牌
		var zhuangs1 = "" ;  //庄家开奖第一张牌
		
		var zd;//庄家的点数
		var xd;//闲家的点数
	
		var x1 = xian1.split(",");//闲家第一张牌
		var x2 = xian2.split(",");//闲家第二张牌
		var  xbp = ""; //闲家补牌
		
		var z1 = zhuang1.split(",");//庄家的第一张牌
		var z2 = zhuang2.split(",");//庄家的第二张牌
		var zbp = "";//庄家不牌
		//闲家判断
		if(x1[1] != "j" && x1[1] != "q" && x1[1] != "k" && x1[1] != "a"){
			xd=parseInt(x1[1])
		}else if(x1[1] == "a"){
			xd=1
		}else{
			xd=0
		}
		if(x2[1] != "j" && x2[1] != "q" && x2[1] != "k" && x2[1] != "a"){
			xd+=parseInt(x2[1])
		}else if(x2[1] == "a"){
			xd+=1
		}
		if(xd >= 10){//当大于10去掉前面第一个数字
			if(xd != 11){
				xd  = parseInt(String(xd).replace("1",""))
			}else{
				xd = 1
			}
		}
		//庄家判断
		if(z1[1] != "j" && z1[1] != "q" && z1[1] != "k" && z1[1] != "a"){
			zd=parseInt(z1[1])
		}else if(z1[1] == "a"){
			zd=1
		}else{
			zd=0
		}
		if(z2[1] != "j" && z2[1] != "q" != z2[1] != "k" && z2[1] != "a"){
			zd = zd+parseInt(z2[1])
		}else if(z2[1] == "a"){
			zd+=1
		}
		if(zd >= 10){//当大于10去掉前面第一个数字
			if(zd != 11){
				zd = parseInt(String(zd).replace("1",""))
			}else{
				zd = 1
			}
		}
		frontPointsOfZhuangshi = zd;//庄家补牌前点数
		frontPointsofIdleReplacementCards = xd;//闲家补牌前点数
		if(zd >= 8 || xd >=8){//天生赢家 不需要都不需要补牌
			if(leisureCard != ""){
				layer.alert("天生赢家不需要补牌")
				return;
			}
			if(zhuangBuBrand != ""){
				layer.alert("天生赢家不需要补牌");
				return;
			}
			//判断是否有任意对子
			if(z1[1] == z2[1]  || x1[1] == x2[1]){
				arbitraryPairs = 1;
			}else{
				arbitraryPairs = 0;
			}
			//判断是否有庄对
			if(z1[1] == z2[1] ){
				zhuangPairs = 1;
			}else{
				zhuangPairs = 0;
			}
			//判断是否有闲对
			if(x1[1] == x2[1]){
				idleTime = 1;
			}else{
				idleTime = 0;
			}
		}else{
			if(xd == 0 || xd == 1 || xd == 2 || xd == 3 || xd == 4 || xd == 5){//闲家需要补牌 
				if(leisureCard == ""){
					layer.alert("闲家需要补牌")
					return ;
				}
			}
			if(xd == 6 || xd == 7 || xd == 8 || xd == 9){//闲家不需要补牌
				if(leisureCard != ""){
					layer.alert("闲家不需要补牌")
					return;
				}
			}
			if(leisureCard != ""){//撇开闲家补牌
				xbp = leisureCard.split(",");
				if(xbp[1] != "j" && xbp[1] != "q" && xbp[1] != "k" && xbp[1] != "a"){
					xd+=parseInt(xbp[1])
				}else if(xbp[1] == "a"){
					xd+=1
				}
			}
			if(zd == 0 || zd == 1 || zd == 2){//庄家需要补牌
				if(zhuangBuBrand == ""){
					layer.alert("庄家需要补牌");
					return;
				}
			}
			if(zd == 3){//当闲家补得第三张牌是8时 不需要补牌 其余补牌
				if(leisureCard == ""){
					//庄家需要补牌
					if(zhuangBuBrand == ""){
						layer.alert("庄家需要补牌");
						return;
					}
				}else{
					if(parseInt(xbp[1]) == 8){//当闲家补得第三张牌是8的时候
						if(zhuangBuBrand != ""){
							layer.alert("闲家补得第三张牌为8庄家不可以补牌");
							return;
						}
					}else{
						//需要补牌
						if(zhuangBuBrand == ""){
							layer.alert("庄家需要补牌");
							return;
						}
					}
				}
			}
			if(zd == 4){//当闲家补得第三张牌是0.1.8.9，不须补牌；其余则须补牌
				if(leisureCard == ""){
					//需要补牌
					if(zhuangBuBrand == ""){
						layer.alert("庄家需要补牌");
						return;
					}
				}else{
					if(parseInt(xbp[1]) == 0 || parseInt(xbp[1]) == 1 || parseInt(xbp[1]) == 8 || parseInt(xbp[1]) == 9){
						if(zhuangBuBrand != ""){
							layer.alert("闲家补得第三张牌为0或1或8或9庄家不可以补牌");
							return;
						}
					}else{
						//需要补牌
						if(zhuangBuBrand == ""){
							layer.alert("庄家需要补牌");
							return;
						}
					}
				}
			}
			if(zd == 5){//当闲家补得第三张牌是0.1.2.3.8.9，不须补牌；其余则须补牌
				if(leisureCard == ""){
					//需要补牌
					if(zhuangBuBrand == ""){
						layer.alert("庄家需要补牌");
						return;
					}
				}else{
					if(parseInt(xbp[1]) == 0 || parseInt(xbp[1]) == 1 || parseInt(xbp[1]) == 2 || parseInt(xbp[1]) == 3 || parseInt(xbp[1]) == 8 || parseInt(xbp[1]) == 9){
						//不需要补牌
						if(zhuangBuBrand != ""){
							layer.alert("闲家补得第三张牌为0或1或8或9庄家不可以补牌");
							return;
						}
					}else{
						//需要补牌
						if(zhuangBuBrand == ""){
							layer.alert("庄家需要补牌");
							return;
						}
					}
				}
			}
			if(zd == 6){//当闲家补得第三张牌是0.1.2.3.4.5.8.9，不须补牌；其余则须补牌
				if(leisureCard == ""){
					//需要补牌
					if(zhuangBuBrand == ""){
						layer.alert("庄家需要补牌");
						return;
					}
				}else{
					if(parseInt(xbp[1]) == 0 || parseInt(xbp[1]) == 1 || parseInt(xbp[1]) == 2 || parseInt(xbp[1]) == 3 || parseInt(xbp[1]) == 4 ||  parseInt(xbp[1]) == 5 || parseInt(xbp[1]) == 8 || parseInt(xbp[1]) == 9){
						//不需要补牌
						if(zhuangBuBrand != ""){
							layer.alert("闲家补得第三张牌为0或1或8或9庄家不可以补牌");
							return;
						}
					}else{
						//需要补牌
						if(zhuangBuBrand == ""){
							layer.alert("庄家点数为7或8或9点不可以补牌");
							return;
						}
					}
				}
			}
			if(zd == 7 || zd == 8 || zd == 9){
				//不需要补牌
				if(zhuangBuBrand != ""){
					layer.alert("庄家点数为7或8或9点不可以补牌"); 
					return;
				}
			}
			if(zhuangBuBrand != ""){//抛开庄家补的牌
				zbp = zhuangBuBrand.split(",");
				if(zbp[1] != "j" && zbp[1] != "q" && zbp[1] != "k" && zbp[1] != "a"){
					zd+=parseInt(zbp[1])
				}else if(zbp[1] == "a"){
					zd+=1
				}
			}
			//判断是否有任意对子
			if(zbp != ''){
				if(xbp != ''){// 庄家 闲家都 在补牌的情况下进来
					if(x1[1] == x2[1] || x1[1]==xbp[1] ||  x2[1]==xbp[1]
						|| z1[1] == z2[1] ||  z1[1] == zbp[1] ||  z2[1] == zbp[1]){
						arbitraryPairs = 1;
					}else{
						arbitraryPairs = 0;
					}
				}else{//闲家没有补牌的情况下进来
					if(x1[1] == x2[1] 
						|| z1[1] == z2[1] ||  z1[1] == zbp[1] ||  z2[1] == zbp[1]){
						arbitraryPairs = 1;
					}else{
						arbitraryPairs = 0;
					}
				}
			}else{//庄家没有补牌的情况下进来
				if(xbp != ''){//闲家在补牌的情况下进来  
					if(x1[1] == x2[1] || x1[1]==xbp[1] ||  x2[1]==xbp[1]
						|| z1[1] == z2[1]){
						arbitraryPairs = 1;
					}else{
						arbitraryPairs = 0;
					}
				}else{//两家都没有补到牌的情况下进来
					if(x1[1] == x2[1] || z1[1] == z2[1]){
						arbitraryPairs = 1;
					}else{
						arbitraryPairs = 0;
					}
				}
				
			}
			//判断是否有庄对
			if(zbp != ''){
				if(z1[1] == z2[1]  ||z1[1] == zbp[1]  || z2[1] == zbp[1]){
					zhuangPairs = 1;
				}else{
					zhuangPairs = 0;
				}
			}else{
				if(z1[1] == z2[1]){
					zhuangPairs = 1;
				}else{
					zhuangPairs = 0;
				}
			}
			//判断是否有闲对
			if(xbp != ''){//闲家补牌为空的情况下 就不用判断闲家的补牌了 直接判断闲家的第一张牌和第二张牌即可
				if(x1[1] == x2[1] || x1[1] == xbp[1] || x2[1] == xbp[1]){
					idleTime = 1;
				}else{
					idleTime = 0;
				}
			}else{
				if(x1[1] == x2[1]){
					idleTime = 1;
				}else{
					idleTime = 0;
				}
			}
		}
		//以上是判断填写进来的值是否正确
		zhuangs1 = String(zhuang1).replace(",","");//去逗号
		zhuangs2 = String(zhuang2).replace(",","");//去逗号
		if(zhuangBuBrand != ""){
			dealerCards = String(zhuangBuBrand).replace(",","");
		}
		leisures1 = String(xian1).replace(",","");
		leisures2 = String(xian2).replace(",","");
		if(leisureCard != ""){
			leisureCards = String(leisureCard).replace(",","");
		}
		//判断大小
		if(zhuangBuBrand != "" || leisureCard != ""){
			size = 1;
		}else{
			size = 0;
		}
		//判断是否有完美对子
		if(leisures1 == leisures2 || leisures1==leisureCards || leisures2==leisureCards 
		|| zhuangs1 == zhuangs2 || zhuangs1 == dealerCards ||  zhuangs2 == dealerCards
		){
			perfectPair = 1;
		}else{
			perfectPair = 0;
		}
		//判断赢家
		if(zd > xd){//开奖状态  0-闲家赢 1-庄家赢  2-和局
			//庄赢
			winner = 1;
		}else if(xd > zd){
			//闲赢
			winner = 0;
		}else if(zd == xd){
			//和局
			winner = 2;
		}
		leisureHomePoints = xd;//闲家最终点数
		makerSFinalPoints = zd;//庄家最终点数
		var ajax = $.ajax({//将预设数据发送给服务器
			url:'/bjlhtgl/baccaratPresupposition.do',
			type:'post',
			data:{
				arbitraryPairs:arbitraryPairs, //任意对子 0-没有任意对子  1有任意对子',
				perfectPair: perfectPair,//'完美对子 0-没有完美对子   1-有完美对子',
				size: size,// '0-小   1-大',
				zhuangPairs: zhuangPairs,//庄对 0-没有庄对 1-有庄对
				idleTime: idleTime,//闲对 0-没有闲对 1-有闲对
				winner: winner, //开奖状态  0-闲家赢 1-庄家赢  2-和局
				leisureHomePoints:leisureHomePoints,//闲家最终点数
				makerSFinalPoints: makerSFinalPoints,//庄家最终点数
				frontPointsofIdleReplacementCards: frontPointsofIdleReplacementCards,//闲家补牌前点数
				frontPointsOfZhuangshi: frontPointsOfZhuangshi,//庄家补牌前点数
				leisureCard: leisureCards,//闲家补牌
				leisure2: leisures2,//闲家第二张牌
				leisure1: leisures1,//闲家第一张牌
				dealerCard: dealerCards,//庄家补牌
				zhuang2: zhuangs2,//庄家开奖第二张牌
				zhuang1: zhuangs1,  //庄家开奖第一张牌
				tableNumber: tableNumber,//开奖桌号
				issueNumber: issueNumber,//开奖期号
			},
			success:function(data){
				if(data.data == 1){
					layer.alert("恭喜你预设开奖数据成功");
					$("#table_id_bjl").DataTable().ajax.reload()
					$("#button-i-bjlCard").text("修改")
					return;
				} else if(data.data == 5){
					layer.alert("本期已开奖请预设下一期把");
					$("#table_id_bjl").DataTable().ajax.reload()
					$("#button-i-bjlCard").text("修改")
					return;
				}
				layer.alert("很遗憾！你数据填写不对预设失败,也可能是系统bug请联系技术人员查看,保留当前预设数据,以方便技术人员查看");
				return;
			}
		});
		return ajax;
	} */
		
	</script>
	</body>
</html>








